package com.imy.common.base.adapter;



import java.util.List;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;


public class ViewPagerAdapter extends FragmentPagerAdapter {
  private List<Fragment> fragments;

  private List<String> title;
  public ViewPagerAdapter(FragmentManager fm, List<Fragment> fragments,List<String> title) {
    super(fm);
    this.fragments = fragments;
    this.title=title;
  }

  @Override
  public CharSequence getPageTitle(int position) {
    if (title!=null && title.size()>0){
      return title.get(position);
    }else {
      return "";
    }

  }

  @Override
  public int getCount() {
    if (fragments != null) {
      return fragments.size();
    } else {
      return 0;
    }
  }

  @Override
  public Fragment getItem(int position) {
    return fragments.get(position);
  }

  @Override
  public int getItemPosition(Object object) {
    return super.getItemPosition(object);
  }
}
